﻿using System;
using System.Collections.Generic;
using System.Linq;

using System.Web.Mvc;
using Prodma.DataAccess.Database;
using Prodma.DataAccess.Models;
using Prodma.DataAccess.Helper.Enumerators;
using System.Web.UI.WebControls;
using System.Web.Mvc;


namespace Prodma.DataAccess.DataService.ListService
{
    public class ProductCategoryList
    {
        private static DataContext context = new DataContext();

        public static SelectList GetList()
        {
            DataContext context = new DataContext();
            using (context)
            {
                var list = (from cat in context.MARKA
                            select cat);

                SelectList selectList = new SelectList(list.ToDictionary(x => x.ID, z => z.AD),"Key","Value");
                return selectList;
            }
        }

        public static SelectList GetModels(int markaId)
        {
            DataContext context = new DataContext();
            using (context)
            {
                var modelList = (from model in context.MODEL
                                 where model.MARKA_ID == markaId
                                 select model);

                SelectList selectList = new SelectList(modelList.ToDictionary(x => x.ID, z => z.AD),"Key","Value");
                return selectList;
            }
        }
        public static SelectList GetModels()
        {
            DataContext context = new DataContext();
            using (context)
            {
                var modelList = (from model in context.MODEL
                                 select model);

                SelectList selectList = new SelectList(modelList.ToDictionary(x => x.ID, z => z.AD), "Key", "Value");
                return selectList;
            }
        }

        public static SelectList GetList(int brandId)
        {
            
            DataContext context = new DataContext();
            using (context)
            {
                var list = (from cat in context.tb_Product_Category
                            where cat.tb_Product_Category2.Id == brandId
                            select cat);

                SelectList selectList = new SelectList(list.ToDictionary(x => x.Id, z => z.Name), "Value", "Text");
                return selectList;
            }
        }

        

        
    }
}
